#include <stdio.h>

int a[100] = {0};
int i = 0;

int NumberOf1(unsigned int n) {
	int number = 0;
	while (n) {
		if (n % 10 == 1)
			number ++;

		n = n / 10;
	}

	return number;
}

int NumberOf2(unsigned int n) {
	int number = 0;
	int m = n;
	while (n) {
		if (n % 10 == 1)
			number ++;

		n = n / 10;
	}
	if (number != 0) {
		a[i++] = m;
		return number;
	}

	return number;
}

int NumberOf1BeforeBetween1AndN_Solution1(unsigned int n) {
	int number = 0;

	// Find the number of 1 in each integer between 1 and n
	for (unsigned int i = 1; i <= n; ++ i)
		number += NumberOf1(i);

	return number;
}

int NumberOf1BeforeBetween1AndN_Solution2(unsigned int n) {
	int number = 0;

	// Find the number of 1 in each integer between 1 and n
	for (unsigned int i = 1; i <= n; ++ i)
		number += NumberOf2(i);

	return number;
}



int main() {
	int n;
	scanf("%d", &n);
	int m = NumberOf1BeforeBetween1AndN_Solution1(n);
	printf("%d\n", m);
	NumberOf1BeforeBetween1AndN_Solution2(n);
	for (int j = i - 1; j > 0; j--) {
		printf("%d ", a[j]);
	}
	printf("%d", a[0]);
}
